﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace VFCons
{
	public partial class MatchParamPanel : UserControl
	{
		public MatchParamPanel()
		{
			InitializeComponent();

			comboBox1.DropDownStyle = ComboBoxStyle.DropDownList;
			comboBox1.DisplayMember = "Item1";
			comboBox1.ValueMember = "Item2";
			List<Tuple<string, int>> items = new List<Tuple<string, int>>()
			{
				new Tuple<string, int>("24",24),
				new Tuple<string, int>("32",32),
				new Tuple<string, int>("64",64),
				new Tuple<string, int>("128",128),
			};
			comboBox1.DataSource = items;
			comboBox1.SelectedValue = 64;

			comboBox2.DropDownStyle = ComboBoxStyle.DropDownList;
			comboBox2.DisplayMember = "Item1";
			comboBox2.ValueMember = "Item2";
			List<Tuple<string, int>> items2 = new List<Tuple<string, int>>()
			{
				new Tuple<string, int>("1",1),
				new Tuple<string, int>("2",2),
				new Tuple<string, int>("3",3),
			};
			comboBox2.DataSource = items2;
			comboBox2.SelectedValue = 3;
		}

		public int Similarity
		{
			get
			{
				try
				{
					int iv = Convert.ToInt32(textBoxSimilarity.Text);
					return iv;
				}
				catch (Exception ex)
				{
					MessageBox.Show(this, "匹配率输入错误" + Environment.NewLine + ex.Message, "ERROR");
					return 80;
				}
			}
			set { textBoxSimilarity.Text = value.ToString(); }
		}


		public int RequireCount
		{
			get
			{
				try
				{
					int iv = Convert.ToInt32(textBoxCount.Text);
					return iv;
				}
				catch (Exception ex)
				{
					MessageBox.Show(this, "目标个数输入错误" + Environment.NewLine + ex.Message, "ERROR");
					return 0;
				}
			}
			set { textBoxCount.Text = value.ToString(); }
		}
		public int NumFeatures
		{
			get { return (int)comboBox1.SelectedValue; }
			set { comboBox1.SelectedValue = value; }
		}

		public int Pyramid
		{
			get { return (int)comboBox2.SelectedValue; }
			set { comboBox2.SelectedValue = value; }
		}

		public int WeakThresh
		{
			get
			{
				try
				{
					int iv = Convert.ToInt32(textBoxThreshWeak.Text);
					return iv;
				}
				catch (Exception ex)
				{
					MessageBox.Show(this, "低阈值输入错误" + Environment.NewLine + ex.Message, "ERROR");
					return 30;
				}
			}
			set { textBoxThreshWeak.Text = value.ToString(); }
		}

		public int StrongThresh
		{
			get
			{
				try
				{
					int iv = Convert.ToInt32(textBoxThreshStrong.Text);
					return iv;
				}
				catch (Exception ex)
				{
					MessageBox.Show(this, "高阈值输入错误" + Environment.NewLine + ex.Message, "ERROR");
					return 30;
				}
			}
			set { textBoxThreshStrong.Text = value.ToString(); }
		}

		public float DegreeBegin
		{
			get
			{
				try
				{
					float iv = Convert.ToSingle(textBoxDegreeBegin.Text);
					return iv;
				}
				catch (Exception ex)
				{
					MessageBox.Show(this, "开始角度输入错误" + Environment.NewLine + ex.Message, "ERROR");
					return -179.0F;
				}
			}
			set { textBoxDegreeBegin.Text = value.ToString("F1"); }
		}

		public float DegreeEnd
		{
			get
			{
				try
				{
					float iv = Convert.ToSingle(textBoxDegreeEnd.Text);
					return iv;
				}
				catch (Exception ex)
				{
					MessageBox.Show(this, "结束角度输入错误" + Environment.NewLine + ex.Message, "ERROR");
					return 180.0F;
				}
			}
			set { textBoxDegreeEnd.Text = value.ToString("F1"); }
		}

		public float DegreeStep
		{
			get
			{
				try
				{
					float iv = Convert.ToSingle(textBoxDegreeStep.Text);
					return iv;
				}
				catch (Exception ex)
				{
					MessageBox.Show(this, "角度步数输入错误" + Environment.NewLine + ex.Message, "ERROR");
					return 1.0F;
				}
			}
			set { textBoxDegreeStep.Text = value.ToString("F1"); }
		}

		public int MaxCount
		{
			get
			{
				try
				{
					int mc = Convert.ToInt32(textBoxMaxCount.Text);
					return mc;
				}
				catch (Exception ex)
				{
					MessageBox.Show(this, "最大个数输入错误" + Environment.NewLine + ex.Message, "ERROR");
					return 7; ;
				}
			}
			set { textBoxMaxCount.Text = value.ToString(); }
		}
	}
}
